Skip to content

Change utcNow() tests to use regex for validation #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 12, 2025

Conversation

SteveL-MSFT
Copy link
Member

PR Summary

utcNow() tests have proven to be fragile due to a race condition of when the function is called and when the PowerShell equivalent used for comparison is called. In particularly if the second, minute, or hour just clicked over, then it fails.

Since we are primarily focused on the format, use a regex to verify instead of trying to verify the value.

@SteveL-MSFT SteveL-MSFT requested review from tgauth and Copilot August 8, 2025 19:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the utcNow() function tests to use regex validation instead of direct datetime comparisons, addressing race condition issues where timing differences between the function call and PowerShell equivalent could cause test failures.

  • Replace direct datetime value comparisons with regex pattern matching
  • Add comprehensive regex patterns for different datetime formats
  • Include additional test case for ISO format with seconds

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Aug 12, 2025
Merged via the queue into PowerShell:main with commit d4cee44 Aug 12, 2025
6 of 7 checks passed
@SteveL-MSFT SteveL-MSFT deleted the utcnow-tests branch August 12, 2025 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants